package com.jin.springcloud.eurekaclient.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class IndexController {
    @Value("${spring.application.name}")
    private String appName;
    @Value("${server.port}")
    private String port;

    @GetMapping("/whichServer")
    public String whichServer(){
        return String.format("The application name is %s, port is %s", appName, port);
    }

    @GetMapping("/hi")
    public String hi(@RequestParam(required = false, defaultValue = "anonymous") String name) {
        return String.format("Hi %s,the server port is %s", name, port);
    }

    @GetMapping("/test")
    public String test() {
        return "Eureka-client server return the test info.";
    }
}
